<template>
	<view>
		<!-- <button  @click="refresh">
		    <text class="">刷新数据</text>
		</button> -->
	<!-- 	<uni-row>
			<uni-col style="padding-top: 10px" v-if="back">
				<button class="" @click="goBack">
					<text class="buttontext">返回走势图</text>
				</button>
			</uni-col>
		</uni-row> -->
		<uni-card>
			<uni-row v-for="item in records" :key="item.id" style="line-height: 42px">
				<!-- <uni-col :span="12">
					  <text>{{item.time}}</text>
				 </uni-col> -->
				 <uni-col :span="9">
				 	<text>{{lotteryType[item.type]}}</text>
				 </uni-col>
				<uni-col :span="9">
					<text v-if="item.hundredOne==''">{{ item.optionName + (item.hundredOne + 1) }}</text>
					<text v-else="item.hundredOne==''">{{ item.optionName}}</text>
				</uni-col>
				<!-- 	 <uni-col :span="3">
					 <uni-icons type="eye" @click="toTrendChart(item)" size="25"  style="color:#007BFF"></uni-icons>
				 </uni-col> -->
				<uni-col :span="3">
					<uni-icons type="compose" @click="toUpdateTrendChart(item)" style="color: #742305" size="25"></uni-icons>
					<!-- <text @click="toUpdateTrendChart(item)" style="color:#007BFF" >修改记录</text> -->
				</uni-col>
				<uni-col :span="3">
					<uni-icons type="trash" @click="deleteRecoredById(item.id)" style="color: #742305" size="25"></uni-icons>
				</uni-col>
			</uni-row>
		</uni-card>
	</view>
</template>

<script>
export default {
	data() {
		return {
			records: [], // 数据操作记录
			lotteryType: {'plw': '排列三', "fcsd": '福彩3D' ,"plwa3":"排五后三"},
			lotteryName: '',
			back: false,
			record: [],
			type:"plw"
		};
	},
	onLoad(query) {
		// 当前页面
		//const currentPageStack = getCurrentPages(); // 获取当前页面栈
		//const currentPage = currentPageStack[currentPageStack.length - 1]; // 当前页面
		//this.record = currentPage.records[0]
		let from = uni.getStorageSync('from');
		if (from == 1) {
			this.back = true;
			this.record = uni.getStorageSync('data');
			uni.setStorageSync('data', 0);
			uni.setStorageSync('from', 0);
		} else {
			this.back = false;
		}
		this.type = query.type
		this.getRecord();
	},
	methods: {

		tyuhuab() {
			//查看走势图 跳转页面
			uni.navigateTo({
				url: '/pages/trendChart/trendChart?record=' + JSON.stringify(this.record)
			});
		},
		// 返回上一页
		goBack() {
			//查看走势图 跳转页面
			uni.navigateTo({
				url: '/pages/trendChart/trendChart?record=' + JSON.stringify(this.record)
			});
		},
		type(type) {
			let l = this.lotteryType.find((res) => res.name == type);
			return l.value;
		},
		refresh() {
			this.getRecord();
		},
		toTrendChart(item) {
			// 查看条状走势图页面
			uni.navigateTo({
				url: `/pages/trendChart/trendChart?updateFlag=0&record=${JSON.stringify(item)}`
			});
		},
		toUpdateTrendChart(item) {
			// 修改走势图页面
			uni.navigateTo({
				url: `/pages/trendChart/trendChart?updateFlag=1&record=${JSON.stringify(item)}`
			});
		},
		deleteRecoredById(id) {
			let that = this;
			uni.showModal({
				title: '提示',
				content: '确定要删除该记录信息吗？',
				success: function (res) {
					if (res.confirm) {
						// 用户点击确定
						that.$myRequest({
							method: 'delete',
							url: '/deleteRecordById?id=' + id
							//data: data
						}).then((res) => {
							if (res.flag) {
								uni.showToast({
									title: '删除记录成功！'
								});
								that.getRecord(); // 刷新记录
							} else {
								uni.showToast({
									title: '删除记录失败！'
								});
							}
						});

						// 在这里执行删除操作
					} else if (res.cancel) {
						// 用户点击取消
						console.log('用户点击了取消');
					}
				}
			});
		},
		getRecord() {
			// 获取自己提交得记录
			const deviceId = uni.getStorageSync("phone");
			this.$myRequest({
				method: 'get',
				url: '/getRecordByDeviceId?deviceId=' + deviceId+"&type="+this.type
				//data: data
			}).then((res) => {
				let data = res.data;
				if (res.data) {
					this.records = data;
				} else {
					uni.showToast({
						title: '您还未提交记录！'
					});
				}
			});
		}
	}
};
</script>

<style>


.checkbox1 {
	margin-top: -10px;
}
.checkbox2 {
	display: flex;
	width: 400px;
}
.combinatorialArrayAll {
	background-color: white;
	margin-top: 20px;
}
.demo-uni-row1 {
	width: 500px;
	margin-top: 30rpx;
	display: flex;
}
.combinatorialArray {
	width: 100%;
}
.titletext {
	background-color: #aa0000;
}
.zygocouple {
	display: flex; /* 使用flex布局 */
	flex-wrap: nowrap; /* 不换行，保证子元素在一行内显示 */
	justify-content: center; /* 水平居中 */
	align-items: center; /* 垂直居中 */
	border: 1px solid black;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	margin-top: -5px;
}
</style>
